	handle_events_on_filter = false;
    refill_original_value_on_filter = false;
    auto_enable_disable = false;

    // Gets the value of a select
    function getValue(SelectToGet)
		{
		// Create array to return.
		var SelectedArray = new Array();

		//loop through options, put selected into an array and return
		if (!(SelectToGet.selectedIndex >= 0))
			{ return SelectedArray; }
		else if (SelectToGet.type.toLowerCase() == 'select-one')
			{ SelectedArray[SelectedArray.length] = SelectToGet.options[SelectToGet.selectedIndex].value; }
		else
			{
			for (var optionIndex=0; optionIndex < SelectToGet.options.length; optionIndex++)
				if (SelectToGet.options[optionIndex].selected)
					SelectedArray[SelectedArray.length] = SelectToGet.options[optionIndex].value;
			}
		return SelectedArray;
		}

    // Gets the value of a select
    function getSelected(SelectToGet)
         {
         return (SelectToGet.selectedIndex >= 0) ? SelectToGet.options[SelectToGet.selectedIndex] : false;
         }

    // Creates an array in the format SelectName_Array
    function createArray(SelectToArray)
         {
         ArrayName = SelectToArray.name + "_Array"
         eval(ArrayName + " = new Array()");
         setArray(SelectToArray)
         }

    // Fill associated array with elements from select
    // Each element of array is an array in format [filter, text, value]
    function setArray(SelectToSet)
         {
         var SelectArray = eval(SelectToSet.name + "_Array")
         var SetArrayStart = ((SelectToSet.options.length) && (SelectToSet.options[0].value == "")) ? 1:0;
         for(var optionIndex=SetArrayStart; optionIndex<SelectToSet.options.length; optionIndex++)
         	{
         		var optionObj = SelectToSet.options[optionIndex];
         		var filterValue = (optionObj.filter) ? optionObj.filter : optionObj.getAttribute('filter');
	            SelectArray[SelectArray.length] = [ filterValue, optionObj.text, optionObj.value ];
            }
         }

    // Set each option other than first to null to release, then set count to one
    function clearSelect(SelectToClear)
         {
         with(SelectToClear)
              {
              var ClearStart = ((options.length) && (options[0].value == "")) ? 1:0;
              for(var optionIndex=ClearStart; optionIndex<options.length; optionIndex++)
                   options[optionIndex] = null;
              // release memory, but leave first option.
              SelectToClear.length = ClearStart;
              }
         }

    // create new instance of option, and set filter var
    function addOption(SelectToFilter,filter,text,value)
         {
         SelectToFilter.options[SelectToFilter.options.length] = new Option(text,value);
         SelectToFilter.options[SelectToFilter.options.length-1].filter = filter;
         }

    // Returns true if the element is found in the array, false otherwise
    function IsInArray(SearchArray,SearchValue)
         {
         if ( typeof(SearchArray) == 'string' )
              {
              // Convert to an array
              if ( SearchArray.indexOf(",") >= 0 )
                   { SearchArray = SearchArray.split(","); }
              // Compare strings
              else { return (SearchArray == SearchValue); }
              }

         if ( typeof(SearchArray) != 'undefined' )
              {
              // Flip through array, and return true is value found
              for(var arrayIndex=0; arrayIndex<SearchArray.length; arrayIndex++)
                   if(SearchArray[arrayIndex] == SearchValue)
                        { return true; }
              }

         return false;
         }

    // Enables and disabled the selects based if the value is not null
    function enableDisableSelect(SelectToEnableDisable,BasedOnSelect)
         {
         var sentinal = false;
         if (typeof(BasedOnSelect) == 'object')
              { sentinal = (getSelected(BasedOnSelect).value == ''); }
         else
              { sentinal = ((BasedOnSelect.length == 0) || (!BasedOnSelect)); }
         SelectToEnableDisable.disabled = sentinal;
         }

    // Clear select, filter array, then insert appropriate options
    function filterSelect(SelectToFilter,FilterFromSelect,enableDisable)
         {
         // Get the filter value, and determine if you should refill the entire select
         if (typeof(FilterFromSelect) == 'object')
              {
              var filter = getValue(FilterFromSelect);
              var RefillAll = ((filter == "") && (FilterFromSelect.selectedIndex <= 1));
              }
         else
              {
              var filter = FilterFromSelect;
              var RefillAll = (filter == "");
              }
         // Check if we want to enable and disable the select based on what is selected
		if (enableDisable == null) { enableDisable = auto_enable_disable; }
		if (enableDisable) { enableDisableSelect(SelectToFilter,FilterFromSelect); }

         // After we filter the select we'll look for this value and set it selected again
         var OriginalValue = (getSelected(SelectToFilter)) ? getSelected(SelectToFilter).value : "";

         // Check if an associated array already exists for select, if not create one
         ArrayString = "typeof(" + SelectToFilter.name + "_Array)"
         if (eval(ArrayString) == 'undefined')
              createArray(SelectToFilter);

         // Clear the current values of the select
         clearSelect(SelectToFilter);

         // Refill the select from the associated array if the filter criteria match
         for(var arrayIndex=0; arrayIndex < eval(SelectToFilter.name + "_Array.length"); arrayIndex++)
              {
              if(( IsInArray(filter, eval(SelectToFilter.name + "_Array[" + arrayIndex + "][0]")) ) || (RefillAll))
                   {
                   text = eval(SelectToFilter.name + "_Array[" + arrayIndex + "][1]");
                   value = eval(SelectToFilter.name + "_Array[" + arrayIndex + "][2]");
                   addOption(SelectToFilter,filter,text,value);
                   }
              }

         // Check sibling for an onchange function, and call it if it's not null
         if(RefillAll)
              if(typeof(SelectToFilter.onchange) != 'undefined')
                   if (SelectToFilter.onchange != null)
                        { SelectToFilter.onchange();}

         // If we didn't refill everything, look for the previously selected value
         if ( refill_original_value_on_filter && (OriginalValue != "") && !(RefillAll) )
              {
              for (var optionIndex=0; optionIndex<SelectToFilter.options.length; optionIndex++)
                   {
                   if ( SelectToFilter.options[optionIndex].value == OriginalValue )
                        { SelectToFilter.options[optionIndex].selected = true; break; }
                   }
              }

         if (handle_events_on_filter)
              {
              // Handle the possible events for changing
              if ( (typeof(SelectToFilter.onfocus) != 'undefined') && (SelectToFilter.onfocus != null) ) { SelectToFilter.onfocus(); }
              if ( (typeof(SelectToFilter.onclick) != 'undefined') && (SelectToFilter.onclick != null) ) { SelectToFilter.onclick(); }
              if ( (typeof(SelectToFilter.onchange) != 'undefined') && (SelectToFilter.onchange != null) ) { SelectToFilter.onchange();}
              if ( (typeof(SelectToFilter.onblur) != 'undefined') && (SelectToFilter.onblur != null) ) { SelectToFilter.onblur(); }
              }
         return true;
         }